package bing.commons.xmloperator;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class ReadExactlyXMLAndCopyFile {
	//static String destpath="C:\\Users\\LBH\\Desktop\\jarexport";
	//static String destpath="C:\\Users\\LBH\\Desktop\\jarexport-cassandra";
	static String destpath="C:\\Users\\LBH\\Desktop\\jarexport-others";
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			readxml();
		} catch (DocumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	//	读取的xml文件类型
	//	<?xml version="1.0" encoding="UTF-8"?>
	//	<classpath>
	//		<classpathentry kind="output" path="bin"/>
	//		<classpathentry kind="src" path="src/main/java"/>
	//		<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
	//		<classpathentry sourcepath="C:/Users/user/.gradle/caches/modules-2/files-2.1/javax.ws.rs/javax.ws.rs-api/2.0.1/a20db7429fd8dfff74335ec867472b71c345049b/javax.ws.rs-api-2.0.1-sources.jar" kind="lib" path="C:/Users/user/.gradle/caches/modules-2/files-2.1/javax.ws.rs/javax.ws.rs-api/2.0.1/104e9c2b5583cfcfeac0402316221648d6d8ea6b/javax.ws.rs-api-2.0.1.jar"/>
	//		<classpathentry sourcepath="C:/Users/user/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.5.0/88b177349b719fe0636b50889687b9ed036bfd89/jackson-annotations-2.5.0-sources.jar" kind="lib" path="C:/Users/user/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.5.0/a2a55a3375bc1cef830ca426d68d2ea22961190e/jackson-annotations-2.5.0.jar"/>
	//		<classpathentry sourcepath="C:/Users/user/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/28e0ad201304e4a4abf999ca0570b7cffc352c3c/junit-4.11-sources.jar" kind="lib" path="C:/Users/user/.gradle/caches/modules-2/files-2.1/junit/junit/4.11/4e031bb61df09069aeb2bffb4019e7a5034a4ee0/junit-4.11.jar"/>
	//		<classpathentry sourcepath="C:/Users/user/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/1dc37250fbc78e23a65a67fbbaf71d2e9cbc3c0b/hamcrest-core-1.3-sources.jar" kind="lib" path="C:/Users/user/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar"/>
	//	</classpath>
	public static void readxml() throws DocumentException, IOException {
		SAXReader reader = new SAXReader();
		String parentPath="D:\\projects\\palantirall\\atlasdb-0.3.30\\";
		//api//File file = new File(parentPath+"atlasdb-api\\.classpath");
        
		//cassandra//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-cassandra\\.classpath");
		//cassandra-tests//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-cassandra-tests\\.classpath");
		//client//File file = new File(parentPath+"atlasdb-client\\.classpath");
		//client-protobufs//File file = new File(parentPath+"atlasdb-client-protobufs\\.classpath");
		//commons//File file = new File(parentPath+"atlasdb-commons\\.classpath");
		//config//File file = new File(parentPath+"atlasdb-config\\.classpath");
		//endpoint//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-endpoint\\.classpath");
		//impl-shared//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-impl-shared\\.classpath");
		//lock-api//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-lock-api\\.classpath");
		//partition-manager//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-partition-manager\\.classpath");
		//atlasdb-rdbms//File file = new File("D:\\projects\\javaprojects\\atlasdb-develop\\atlasdb-rdbms\\.classpath");
		//rocksdb//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-rocksdb\\.classpath");
		//rocksdb-tests//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-rocksdb-tests\\.classpath");
		//server//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-server\\.classpath");
		//server-with-endpoint//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-server-with-endpoint\\.classpath");
		//shell//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-shell\\.classpath");
		//spi//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-spi\\.classpath");
		//tests-shared//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\atlasdb-tests-shared\\.classpath");
		//bookkeeper-transaction//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\bookkeeper-transaction\\.classpath");
		//cassandra-partitioner//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\cassandra-partitioner\\.classpath");
		//commons-executors//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\commons-executors\\.classpath");
//		/leader-election-api//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\leader-election-api\\.classpath");
		//leader-election-api//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\leader-election-api\\.classpath");
		//leader-election-impl//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\leader-election-impl\\.classpath");

		//lock-api//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\lock-api\\.classpath");
//		/lock-impl//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\lock-impl\\.classpath");
		//profile-client//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\examples\\profile-client\\.classpath");
		//profile-client-protobufs//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\examples\\profile-client-protobufs\\.classpath");
		//timestamp-api//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\timestamp-api\\.classpath");
		//timestamp-impl//
		//File file = new File("D:\\projects\\javaprojects\\AtlasdbWorkSpace\\timestamp-impl\\.classpath");

		/*****0.3.30*****/
		/*********postgresql keyvalue only begin*************/
		//api//File file = new File(parentPath+"atlasdb-api\\.classpath");
		//client//File file = new File(parentPath+"atlasdb-client\\.classpath");
		//client-protobufs//File file = new File(parentPath+"atlasdb-client-protobufs\\.classpath");
		//commons//File file = new File(parentPath+"atlasdb-commons\\.classpath");
		//config//File file = new File(parentPath+"atlasdb-config\\.classpath");
		//jdbc//File file = new File(parentPath+"atlasdb-jdbc\\.classpath");
		//hikari//File file = new File(parentPath+"atlasdb-hikari\\.classpath");
		//commons-executors//File file = new File(parentPath+"commons-executors\\.classpath");
		//spi//File file = new File(parentPath+"atlasdb-spi\\.classpath");
		//atlasdb-server//File file = new File(parentPath+"atlasdb-server\\.classpath");
		
		//atlasdb-rocksdb//
		File file = new File(parentPath+"atlasdb-rocksdb\\.classpath");

		/*********postgresql keyvalue only end*************/
		
		/*********cassandra keyvalue and transcation begin*************/
		//cassandra//File file = new File(parentPath+"atlasdb-cassandra\\.classpath");
		//cassandra-tests//File file = new File(parentPath+"atlasdb-cassandra-tests\\.classpath");

		//timestamp-api//File file = new File(parentPath+"timestamp-api\\.classpath");
		//timestamp-impl//File file = new File(parentPath+"timestamp-impl\\.classpath");

		/*********cassandra  keyvalue and transcation end*************/
		
		/*********others begin*************/
		//impl-shared//File file = new File(parentPath+"atlasdb-impl-shared\\.classpath");
		//atlasdb-lock-api//File file = new File(parentPath+"atlasdb-lock-api\\.classpath");
		//partition-manager//File file = new File(parentPath+"atlasdb-partition-manager\\.classpath");
		//bookkeeper-transaction//File file = new File(parentPath+"bookkeeper-transaction\\.classpath");
		//cassandra-partitioner//File file = new File(parentPath+"cassandra-partitioner\\.classpath");

		//leader-election-api//File file = new File(parentPath+"leader-election-api\\.classpath");
		//leader-election-api-protobufs//File file = new File(parentPath+"leader-election-api-protobufs\\.classpath");
		//leader-election-impl//File file = new File(parentPath+"leader-election-impl\\.classpath");

		//lock-api//File file = new File(parentPath+"lock-api\\.classpath");
		//lock-impl//File file = new File(parentPath+"lock-impl\\.classpath");

		/*********others end*************/
		/*****0.3.30*****/
		
		
		/****其他项目***/
		//cassandrapac//
		//File file = new File("D:\\projects\\javaprojects\\cassandrapac\\.classpath");
		
		
		
		Document document = reader.read(file);
		Element root = document.getRootElement();
		List<Element> childElements = root.elements();
		for (Element child : childElements) {
			// 未知属性名情况下
			/*
			 * List<Attribute> attributeList = child.attributes(); for
			 * (Attribute attr : attributeList) {
			 * System.out.println(attr.getName() + ": " + attr.getValue()); }
			 */

			// 已知属性名情况下
			File jarfilepath=new File(child.attributeValue("path"));
			if(jarfilepath.getName().endsWith("jar")){
			System.out.println("path: " + child.attributeValue("path"));
			
			JarCopy.copyJarFile(jarfilepath, destpath);
			}
		}
	}
}
